<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form name="form1">
        <h2>form1</h2>
        <p id="p1">
            <input type="checkbox" name="hobbys" value="css">CSS
            <input type="checkbox" name="hobbys" value="html">HTML
            <input type="checkbox" name="hobbys" value="js">JS
            <input type="checkbox" name="hobbys" value="vue">VUE
        </p>
    </form>
    <script>
        document.getElementById('p1').oninput = function () {
            console.log([...document.form1.hobbys].reduce((r, el) => {
                if (el.checked) r.push(el.value);
                return r;
            }, []));
        }

    </script>
</body>

</html>